
function handleRefComment($vessel) {
    var matches;

    matches = $vessel.find('>h4').text().match(/引用来自“(.+?)”的评论/i);

    if (!matches) {

        return;
    }

    if (blockerConfig.blockedUsers.indexOf(matches[1].toLowerCase()) > -1) {

        if ($vessel.find('>.ref').length > 0) {

            handleRefComment($vessel.find('>.ref'));

            $vessel.html(
                $vessel.find('>h4').prop('outerHTML') + 
                $vessel.find('>.ref').prop('outerHTML') + 
                blockerConfig.blockedTips
            );

        } else {

            $vessel.html(
                $vessel.find('>h4').prop('outerHTML') + 
                blockerConfig.blockedTips
            );
        }

    } else if ($vessel.find('>.ref').length > 0) {

         handleRefComment($vessel.find('>.ref'));
    }

}

prLoaded.then(function() {

    $(".comment-item").each(function() {

        var id = $(this).find('.user').text().split("\n", 1)[0].toLowerCase();

        var $content = $(this).find('.comment-content');

        if (blockerConfig.blockedUsers.indexOf(id) >= 0) {

            if ($content.find("> div.ref").length > 0) {

                handleRefComment($content.find('> div.ref'));
                $content.html(
                    $content.find('> div.ref').prop('outerHTML') + 
                    blockerConfig.blockedTips
                );

            } else {

                $content.html(blockerConfig.blockedTips);
            }

        } else if ($content.find("> div.ref").length > 0) {

            handleRefComment($content.find('> div.ref'));
        }
    });

});
